package com.ztmg.common.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;


@ApiModel
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PageReq {
    private static final Integer MAX_LIMIT = 20;
    private static final Integer DEFAULT_PAGE = 1;
    @ApiModelProperty("页码")
    private Integer page = 1;
    @ApiModelProperty("每页个数：默认为20，且最多传20")
    private Integer limit = 20;

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        if (page == null) {
            this.page = DEFAULT_PAGE;
        } else {
            this.page = page;
        }
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        if (limit == null || limit > 20) {
            this.limit = MAX_LIMIT;
        } else {
            this.limit = limit;
        }
    }
}
